1. Field of the Invention
The present invention relates to a method and apparatus for encoding and decoding data in an intra mode, and more particularly, to a method and apparatus for encoding and decoding data in an intra mode based on a multiple scanning method in which an encoding and decoding order is set according to whether a motion estimation reference can be used as a reference for encoding/decoding the data.
2. Description of the Related Art
Recently, codecs of Moving Picture Experts Group (MPEG)-2, MPEG-4, and H.263 use a discrete cosine transform (DCT) of itself as their reference in an intra mode. In the intra mode of H.264, a top macroblock and/or a left macroblock are/is used as its reference.
Referring to FIG. 1, it can be seen that an encoding/decoding order in MPEG-2, MPEG-4, H.263, and H.264 is from left to right, and from top to bottom.
FIG. 2 is a view of an encoding/decoding order in an intra mode of MPEG-2, MPEG-4, and H.263.
First, the encoding order of MPEG-2, MPEG-4, and H.263 is as follows:
(1) An 8×8 block A is obtained. (2) DCT is performed: DCT(A) (3) Quantization is performed: Matrix B=Quantization (DCT(A)) (4) Coefficients of the matrix B (i.e., DCT coefficients) are zigzag scanned, and encoding is performed in an order in which VLC encoding is performed.
The decoding order of MPEG-2, MPEG-4, and H.263 is as follows:
(1) Matrix A is obtained by VLC decoding and zigzag scanning. (2) Dequantization is performed: B=Dequantization(A) (3) Inverse DCT (IDCT) is performed: IDCT(B) (4) Decoding is performed in an order in which the decoded 8×8 block is obtained.
As seen in the encoding and decoding method described above, the coefficients of the matrix B just depend on its 8×8 block frequency coefficients, and are encoded and decoded independently.
FIG. 3 is a view of an encoding/decoding order in an intra mode of H.264.
In H.264, the intra mode is based on DCT conversion of the difference of a 4×4 (or 16×16) block and motion estimation of itself.
First, the encoding order of H.264 is as follows:
(1) A 4×4 (16×16) block matrix A is obtained. (2) Top/left pixels are obtained. (3) An estimation matrix C is obtained from the top/left pixels according to an estimation mode. (4) A difference of A and C is DCT converted: DCT(A-C) (5) Quantization is performed: B=Quantization (DCT(A-C)) (6) Matrix B is zigzag scanned, and VLC encoding is performed.
The decoding order of H.264 is as follows: (1) Matrix A (4×4 or 16×16) is obtained by VLC decoding and zigzag scanning. (2) Dequantization is performed: B=Dequantization(A) (3) IDCT is performed: IDCT(B) (4) Top/left pixels are obtained. (5) An estimation matrix C is obtained from the top/left pixels according to an estimation mode. (6) A decoded block is obtained by adding a result of the IDCT and the matrix C: IDCT(B)+C.
As described above, the coefficients of the matrix B not only depend on the present block but also on its neighbor pixels. In addition, motion estimation of this type can improve the efficiency of a codec. A mode for an encoding and decoding unit is limited in a conventional technology.
That is, in the case of the intra mode of MPEG-2, MPEG-4, and H.263, only frequency coefficients are encoded and the efficiency of a codec is not higher than that of H.264 since the spatial relationship is not used.
In the case of the intra mode of H.264, blocks are encoded from left to right and from top to bottom, the current block can obtain estimation information only from itself or encoded top and left pixels. Thus, its spatial relationship becomes very limited.
Therefore, if a macroblock has an error (caused by an encoder or transmission) therein, a left macroblock in a frame or a slice as described above is also lost and a low peak signal-to-noise ratio occurs.